import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CarouselVO, CarouselForm, CarouselQuery } from '@/api/system/carousel/types';

/**
 * 查询轮播图上传列表
 * @param query
 * @returns {*}
 */

export const listCarousel = (query?: CarouselQuery): AxiosPromise<CarouselVO[]> => {
  return request({
    url: '/system/carousel/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询轮播图上传详细
 * @param carouselId
 */
export const getCarousel = (carouselId: string | number): AxiosPromise<CarouselVO> => {
  return request({
    url: '/system/carousel/' + carouselId,
    method: 'get'
  });
};

/**
 * 新增轮播图上传
 * @param data
 */
export const addCarousel = (data: CarouselForm) => {
  return request({
    url: '/system/carousel',
    method: 'post',
    data: data
  });
};

/**
 * 修改轮播图上传
 * @param data
 */
export const updateCarousel = (data: CarouselForm) => {
  return request({
    url: '/system/carousel',
    method: 'put',
    data: data
  });
};

/**
 * 删除轮播图上传
 * @param carouselId
 */
export const delCarousel = (carouselId: string | number | Array<string | number>) => {
  return request({
    url: '/system/carousel/' + carouselId,
    method: 'delete'
  });
};
